package com.swf.seed.xml.jaxb.monitor;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;

import org.apache.commons.io.IOUtils;
import org.springframework.util.ResourceUtils;

import net.sf.saxon.functions.Root;

public class Excecute {
	public static void main(String[] args) throws Exception {
		File file = ResourceUtils.getFile("classpath:m.xml");
		gernateConfig(file);
	}
	public static void gernateConfig(File file) throws Exception{
			JAXBContext jaxbContext;
			MonitorManager root =null;
			try {
				//加载映射bean类
			   jaxbContext = JAXBContext.newInstance(MonitorManager.class);
	                           //创建解析
			   String buff = IOUtils.toString(new FileInputStream(file));
				Unmarshaller um = jaxbContext.createUnmarshaller();
				StreamSource streamSource = new StreamSource(new StringReader(buff));
				root = (MonitorManager) um.unmarshal(streamSource);
				System.out.println(1);
			} catch (Exception e) {
				e.printStackTrace();
				throw new Exception(e.getMessage());
			}
		}
}

